home *** CD-ROM | disk | FTP | other *** search
/ Gigantic Games 2 / Gigantic Games 2.iso / pc / _w_ / wb_tetris / wbtris_1.4 / source / statistic.c < prev    next >
C/C++ Source or Header  |  1994-12-23  |  3KB  |  115 lines

  1. #include "WBTRIS.h"
  2.  
  3. #define beveloff       50
  4.  
  5.  
  6. __chip UWORD tileData[] = {
  7.     0x0080,0x7F80,0x7F80,0x7F80,0x7F80,0x7F80,0x7F80,
  8.     0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0x8000,
  9. };
  10.  
  11. struct Image tile = {
  12.     0, 0,
  13.     9, 7, 2,
  14.     tileData,
  15.     0x0003, 0x0000,
  16.     NULL
  17. };
  18.  
  19. extern BOOL            UseLace;
  20. extern struct TextAttr helvetica13;
  21. extern struct TextAttr topaz8;
  22.  
  23. int StatisticField[19][4] = {
  24.         {1,1,1,1},{0,0,0,0},{0,0,1,1},{0,1,1,0},{0,0,0,0},{0,1,1,0},{0,0,1,1},{0,0,0,0},
  25.         {0,0,1,0},{0,1,1,1},{0,0,0,0},{0,1,0,0},{0,1,1,1},{0,0,0,0},{0,0,0,1},{0,1,1,1},
  26.         {0,0,0,0},{0,1,1,0},{0,1,1,0}
  27. };
  28.  
  29.  
  30.  
  31. void statistic(WORD WBTRIS_Window_Left, WORD WBTRIS_Window_Top, int ob1, int ob2, int ob3, int ob4, int ob5, int ob6, int ob7)
  32. {
  33.    extern APTR           VisualInfo;
  34.    extern struct Screen *myscreen;
  35.  
  36.    struct Window        *win = NULL;
  37.    int                   i;
  38.    float                 max=0.0;
  39.    float                 laenge;
  40.    float                 objects[7];
  41.    struct IntuiText      Zeile;
  42.    char                  s[80];
  43.    float                 summe = 0;
  44.  
  45.    objects[0] = ob2;
  46.    objects[1] = ob6;
  47.    objects[2] = ob7;
  48.    objects[3] = ob3;
  49.    objects[4] = ob4;
  50.    objects[5] = ob5;
  51.    objects[6] = ob1;
  52.  
  53.    Zeile.FrontPen = 1;
  54.    Zeile.BackPen = 0;
  55.    Zeile.DrawMode = JAM2;
  56.    Zeile.LeftEdge = 0;
  57.    Zeile.TopEdge = 0;
  58.    if (UseLace)
  59.       Zeile.ITextFont = &helvetica13;
  60.    else
  61.       Zeile.ITextFont = &topaz8;
  62.    Zeile.NextText = NULL;
  63.  
  64.    s[0] = '\0';
  65.  
  66.    if (win = OpenWindowTags(NULL,
  67.                             WA_Left,         WBTRIS_Window_Left,
  68.                             WA_Top,          WBTRIS_Window_Top+(myscreen->Font->ta_YSize)+3,
  69.                             WA_Width,        337,
  70.                             WA_Height,       185,
  71.                             WA_CloseGadget,  TRUE,
  72.                             WA_Title,        "<-- Click to close",
  73.                             WA_DragBar,      TRUE,
  74.                             WA_Activate,     TRUE,
  75.                             WA_Flags,        WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_WINDOWACTIVE,
  76.                             WA_IDCMP,        IDCMP_CLOSEWINDOW | IDCMP_RAWKEY,
  77.                             TAG_END)) {
  78.       DrawWin(win,VisualInfo);
  79.       for (i=0;i<7;i++) {
  80.          if (objects[i] > max)
  81.             max = objects[i];
  82.          summe = summe + objects[i];
  83.       }
  84.       if (summe == 0)
  85.          summe = 0.00000001;
  86.       if (max == 0)
  87.          max = 1;
  88.       for (i=0;i<7;i++) {
  89.          laenge = 172*objects[i]/max;
  90.          SetAPen(win->RPort,3);
  91.          RectFill(win->RPort, 47+25, 30-6+(21*i), (short)(25+47+laenge), 30+(21*i)+5);
  92.          sprintf(s, "%5.1f%%", 100*objects[i]/summe);
  93.          Zeile.IText = s;
  94.          PrintIText(win->RPort, &Zeile, 255, 30-4+(21*i));
  95.          s[0] = '\0';
  96.       }
  97.       WaitPort(win->UserPort);
  98.       CloseWindow(win);
  99.    }
  100. }
  101.  
  102.  
  103.  
  104. void DrawWin(struct Window *win,APTR  VisualInfo)
  105. {
  106.    int i,j;
  107.  
  108.    for (i=0;i<4;i++)
  109.       for (j=0;j<19;j++)
  110.          if (StatisticField[j][i] == 1)
  111.             DrawImage(win->RPort,&tile,9*i+25,7*j+30);
  112.          for (i=0;i<7;i++)
  113.             DrawBevelBox(win->RPort, 45+25 , 30-7+(i*21) , 177, 14 ,GTBB_Recessed, TRUE, GT_VisualInfo, VisualInfo);
  114. }
  115.